//$URL: https://dasding.googlecode.com/svn/trunk/api/src/main/java/de/piratech/dasding/api/rest/EventIdResource.java $
//$Id: EventIdResource.java 125 2013-04-07 11:42:35Z krieg.maria@gmail.com $
/*
 * Copyright 2012 Piratech.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package de.piratech.dasding.api.rest;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import de.piratech.dasding.data.Location;
import de.piratech.dasding.data.database.DatabaseException;

/**
 * Resource used api calls for a specific event
 * 
 * @author deveth0
 */
@Path("/locations/id/{id}")
@Component
public class LocationIdResource extends AbstractResource {

  private static final Logger LOG = LoggerFactory
      .getLogger(LocationIdResource.class);

  /**
   * Returns a single event by id
   * 
   * http://localhost:8080/dasding.api/api/events/id/1
   * 
   * GET
   * 
   * @param id
   * @return
   */
  @GET
  @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
  public Location getLocation(@PathParam("id") String id) {
    LOG.debug("getLocation({})", id);
    try {
      return getLocationData().getLocation(id);
    } catch (DatabaseException dbe) {
      throw getBadRequestException(dbe);
    }
  }

  @Override
  protected Logger getLogger() {
    return LOG;
  }
}
